import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "@/components/Layout.vue"
import Home from "@/views/home"
import Member from "@/views/member"
import Supplier from "@/views/supplier"
import Goods from "@/views/goods"
import Staff from "@/views/staff"

Vue.use(VueRouter);

const routes = [
  {
    path: "/login",
    name: "login",
    component: () =>
      import("@/views/login")
  },
  {
    path: "/",
    name: "layout",
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: "/home",
        meta: {title: '首页'},
        component: Home
      }
    ]
  },
  {
    path: "/member",
    component: Layout,
    children: [
      {
        path: "/",
        meta: {title: '会员管理'},
        component: Member
      }
    ]
  },
  {
    path: "/supplier",
    component: Layout,
    children: [
      {
        path: "/",
        meta: {title: '供应商管理'},
        component: Supplier
      }
    ]
  },
  {
    path: "/goods",
    component: Layout,
    children: [
      {
        path: "/",
        meta: {title: '商品管理'},
        component: Goods
      }
    ]
  },
  {
    path: "/staff",
    component: Layout,
    children: [
      {
        path: "/",
        meta: {title: '员工管理'},
        component: Staff
      }
    ]
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
